<template>
  <template v-if="column.children?.length">
    <el-table-column v-if="column.children" :label="column.label">
      <template v-for="childColumn in column.children" :key="childColumn.prop">
        <ColumnItem :column="childColumn">
          <template v-for="(_, name) in $slots" #[name]="scope">
            <slot :name="name" v-bind="scope" />
          </template>
        </ColumnItem>
      </template>
    </el-table-column>
  </template>

  <template v-else>
    <el-table-column :prop="column.prop" :label="column.label" v-bind="column">
      <template #default="{ row, $index }" v-if="$slots[column.prop]">
        <slot :name="column.prop" :row="row" :index="$index" />
      </template>
    </el-table-column>
  </template>
</template>
<script setup>
defineProps({
  column: {
    type: Object,
    default: () => { },
  },
})
</script>
<style lang="scss" scoped></style>
